package com.woniuxy.factory.controller;

import com.woniuxy.factory.entity.Inventory;
import com.woniuxy.factory.entity.ResponseResult;
import com.woniuxy.factory.service.InventoryService;
import com.woniuxy.factory.util.AuditType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 邹佳骏
 * @date 2020-08-24 10:53
 * @name 库存的controller
 */
@Controller
public class InventoryConroller {

    @Autowired
    InventoryService inventoryService;


    @ResponseBody
    @GetMapping("/inventory")
    public ResponseResult<List<Inventory>> selectAll(int page,int limit,Inventory inventory){
        ResponseResult<List<Inventory>> responseResult = new ResponseResult<>();

        int count = inventoryService.selectAllcount();
        List<Inventory> inventories = inventoryService.selectAll(page, limit, inventory);
        if(count==0){
            responseResult.setMsg("暂时无数据");
            return responseResult;
        }

        responseResult.setData(inventories);
        responseResult.setCount(count);
        responseResult.setMsg("查询成功");
        responseResult.setCode(AuditType.No_Approval);

        return responseResult;
    }
}
